package puan.com.weighBox.presenter;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;

import puan.com.weighBox.constants.Constants;
import puan.com.weighBox.viewInterface.ILoginView;

public class LoginPresenter {

    private ILoginView ILoginView;

    public LoginPresenter(puan.com.weighBox.viewInterface.ILoginView ILoginView) {
        this.ILoginView = ILoginView;
    }

    /**
     * 检查登录参数是否合法
     *
     * @param username
     * @param password
     * @return
     */
    public String checkLoginParamsIsLegal(String username, String password) {
        if (StringUtils.isEmpty(username)) {
            ToastUtils.showShort("请输入用户名...");
            return null;
        }
        if (StringUtils.isEmpty(password)) {
            ToastUtils.showShort("请输入密码...");
            return null;
        }
        if (username.equals(Constants.ADMIN_USERNAME) && password.equals(Constants.ADMIN_PASSWORD)) {
            return Constants.ADMIN_USERNAME;
        } else if (username.equals(Constants.OPERATOR_USERNAME) && password.equals(Constants.OPERATOR_PASSWORD)) {
            return Constants.OPERATOR_USERNAME;
        }else {
            ToastUtils.showShort("用户名或密码错误...");
            return null;
        }
    }
}
